package ru.susu.algebra.partition.operation;

import ru.susu.algebra.operation.IOperation;
import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.partition.PartitionsFactory;

/**
 * На входе одно целое число, возвращает ((2m)^2, (2m-2)^2, ..., 2^2)
 *
 * @author akargapolov
 * @since: 03.06.2009
 */
public class SumMPartitionOperation implements IOperation<Partition>
{

	@Override
	public Partition performOperation(Object... sources)
	{
		Integer source = (Integer) sources[0];
		Integer[] array = new Integer[2 * source];
		for (int index = 0;index < array.length;index+=2)
		{
			int tmp = index + 2;
			array[index] = tmp;
			array[index+1] = tmp;
		}
		return PartitionsFactory.createPartition(array);
	}

}
